#pragma once

namespace wxtl
{
	class Fiber
	{
	public:
		Fiber(void* parent);
		virtual ~Fiber(void);

	public:
		void Switch();
		
		static Fiber* Init();
		void Y();
		void SetParent(Fiber* parent);
		bool IsFinished();
		int Get()
		{
			return (int)m_fiber;
		}
		static Fiber& Current();

	protected:
		virtual void Run();

	private:
		static void FiberProc(void*);
		void* m_fiber;
		void* m_parent;
		bool m_finished;
	private:
		Fiber();
		static size_t s_total;
	};
}
